﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using NutriLeaf.Web.Core.Account;

namespace NutriLeaf.Services.Core.Account
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "AccountService" in code, svc and config file together.
    public class AccountService : IAccountService
    {
        public LoginStatus LogIn(string accessToken, DateTime expires)
        {
            NutriLeaf.Web.Model.NutriLeafDBEntities context = new Web.Model.NutriLeafDBEntities();
            return NutriLeaf.Web.Core.Account.Account.LogIn(accessToken, expires, ref context);
        }

        public UserData GetUserData(string accesstoken)
        {
            NutriLeaf.Web.Model.NutriLeafDBEntities context = new Web.Model.NutriLeafDBEntities();
            return NutriLeaf.Web.Core.Account.User.GetUserData(Web.Core.Account.User.GetUserID(accesstoken, ref context), ref context);
        }

        public void UpdateUserData(UserData userdata)
        {
            NutriLeaf.Web.Model.NutriLeafDBEntities context = new Web.Model.NutriLeafDBEntities();
            NutriLeaf.Web.Core.Account.User.UpdateUserData(userdata, ref context);
        }

        public void UpdateUserProfileFromFacebook(string accesstoken)
        {
            NutriLeaf.Web.Model.NutriLeafDBEntities context = new Web.Model.NutriLeafDBEntities();
            NutriLeaf.Web.Core.Account.User.UpdateUserProfile(accesstoken, ref context);
        }

    }
}
